<template>
  <div>
    <!-- 搜索列 -->
    <el-row>
      <el-col :span="6">
        <el-input placeholder="请输入内容" v-model="queryParams.query">
          <el-button
            slot="append"
            @click="handleSearch"
            icon="el-icon-search"
          ></el-button> </el-input
      ></el-col>
    </el-row>
    <el-table
      size="mini"
      style="margin: 20px 0"
      :data="tableData"
      border
      stripe
    >
      <el-table-column type="index" label="#"> </el-table-column>
      <el-table-column prop="order_number" label="订单编号"> </el-table-column>
      <el-table-column prop="order_price" label="订单价格"> </el-table-column>
      <el-table-column prop="pay_status" label="是否付款">
        <template slot-scope="scope">
          <el-tag
            size="mini"
            type="danger"
            effect="dark"
            v-if="scope.row.pay_status === '0'"
            >未付款</el-tag
          >
          <el-tag size="mini" type="success" effect="dark" v-else
            >已付款</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column prop="is_send" label="是否发货"> </el-table-column>
      <el-table-column prop="create_time" label="下单时间"> </el-table-column>
      <el-table-column label="操作">
        <template scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            content="修改订单地址"
            placement="top-start"
          >
            <el-button
              @click="showEdit(scope.row)"
              size="mini"
              type="primary"
              icon="el-icon-edit"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="物流信息"
            placement="top-start"
          >
            <el-button
              size="mini"
              type="success"
              icon="el-icon-location"
            ></el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryParams.pagenum"
      :page-sizes="[10, 15, 20, 40]"
      :page-size="queryParams.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>

    <el-dialog title="修改地址" :visible.sync="showEditDialog">
      <el-form :model="form" label-width="100px" :rules="rules">
        <el-form-item label="省市县">
          <el-cascader
            style="width:100%"
            v-model="form.address"
            :options="options"
            :props="{ expandTrigger: 'hover' }"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址">
          <el-input autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showEditDialog = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getOrderLListApi } from '../../api/orders';

export default {
  data() {
    return {
      form: {
        address: [],
      },
      rules: {},
      queryParams: {
        query: '',
        pagenum: 1,
        pagesize: 10,
      },
      tableData: [],
      total: 0,
      showEditDialog: false,
      options: [

      ],
    };
  },
  methods: {
    showEdit() {
      this.showEditDialog = true;
    },
    handleSizeChange(size) {
      this.queryParams.pagesize = size;
      this.getTableData();
    },
    handleCurrentChange(num) {
      this.queryParams.pagenum = num;
      this.getTableData();
    },
    handleSearch() {
      this.queryParams.pagenum = 1;
      this.getTableData();
    },
    async getTableData() {
      const res = await getOrderLListApi(this.queryParams);
      if (res.meta.status !== 200) return this.$message.success(res.meta.msg);
      this.tableData = res.data.goods;
      this.total = res.data.total;
    },
  },
  created() {
    this.getTableData();
  },
};
</script>

<style>
</style>
